home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / futils / futils~1 / src / misc1s.zoo / misc1 / find-3.2 / configure < prev    next >
Encoding:
Text File  |  1991-08-26  |  9.0 KB  |  341 lines

  1. :
  2. # Guess values for system-dependant variables and create `Makefile'.
  3. # Copyright (C) 1991 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # Usage: configure [+srcdir=DIR] [+host=HOST] [+gas] [+nfp] [TARGET]
  20. # All args except +srcdir=DIR are ignored.
  21.  
  22. trap 'rm -f conftest conftest.c; exit 1' 1 3 15
  23.  
  24. set +u # Make sure unset variables are ok.
  25.  
  26. # Make sure we don't find the System V /etc/install.
  27. PATH=`echo $PATH|sed 's,^:,|,
  28. s,:$,|,
  29. s,:/usr/etc,,g
  30. s,/usr/etc:,,g
  31. s,:/etc,,g
  32. s,/etc:,,g
  33. s,|,:,g'`
  34.  
  35. # A filename unique to this package, relative to the directory that
  36. # configure is in, which we can look for to find out if srcdir is correct.
  37. unique_file=find/pred.c
  38.  
  39. for arg in $*; do
  40.   # Handle +srcdir with a space before the argument.
  41.   if [ x$next_srcdir = xyes ]; then srcdir=$arg; next_srcdir=
  42.   # Handle +host with a space before the argument.
  43.   elif [ x$next_host = xyes ]; then next_host=
  44.   else 
  45.     case $arg in
  46.      -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
  47.     srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'` ;;
  48.      -srcdir | +srcdir | +srcdi | +srcd | +src | +sr | +s)
  49.     next_srcdir=yes ;;
  50.      -host=* | +host=* | +hos=* | +ho=* | +h=*) ;;
  51.      -host | +host | +hos | +ho | +h)
  52.     next_host=yes ;;
  53.      -gas | +gas | +ga | +g) ;;
  54.      -nfp | +nfp | +nf | +n) ;;
  55.      *) ;;
  56.     esac
  57.   fi
  58. done
  59.  
  60. vpsub='s@\$\([-./a-zA-Z0-9]*\)<@\1@g'
  61. # Find the source files, if location was not specified.
  62. if [ x$srcdir = x ]; then
  63.   srcdirdefaulted=yes; srcdir=.
  64.   if [ ! -r $unique_file ]; then srcdir=`pwd`/..; fi
  65. fi
  66. if [ $srcdir != . ]; then
  67.   VPATH='VPATH = $(srcdir)'
  68.   vpsub='s@\$\([-./a-zA-Z0-9]*\)<@\$<@g'
  69. fi
  70.  
  71. if [ ! -r $srcdir/$unique_file ]; then
  72.   if [ x$srcdirdefaulted = xyes ]; then
  73.     echo "$0: Can not find sources in \`.' or \`..'." 1>&2
  74.   else
  75.     echo "$0: Can not find sources in \`${srcdir}'." 1>&2
  76.   fi
  77.   exit 1
  78. fi
  79.  
  80. if test "$RANDOM" = "$RANDOM"; then
  81.   # Plain old Bourne shell.
  82.   echo checking for gcc
  83.   test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O"
  84.  
  85.   echo checking for install
  86.   if test -z "$INSTALL" -a -n "`install 2>&1`"; then
  87.     INSTALL="install -c"
  88.     INSTALLDATA="install -c -m644"
  89.   fi
  90.  
  91.   echo checking for ranlib
  92.   test -z "$RANLIB" -a -n "`ranlib conftest 2>&1`" && RANLIB=ranlib
  93.   rm -f conftest
  94. else
  95.   # ksh, bash or zsh.  ksh and zsh write "command not found" to stderr.
  96.   echo checking for gcc
  97.   test -z "$CC" && type gcc && CC="gcc -O"
  98.  
  99.   echo checking for install
  100.   if test -z "$INSTALL" && type install; then
  101.     INSTALL="install -c"
  102.     INSTALLDATA="install -c -m644"
  103.   fi
  104.  
  105.   echo checking for ranlib
  106.   test -z "$RANLIB" && type ranlib && RANLIB=ranlib
  107. fi
  108.  
  109. CC=${CC-cc}
  110. INSTALL=${INSTALL-cp}
  111. INSTALLDATA=${INSTALLDATA-cp}
  112. RANLIB=${RANLIB-echo}
  113. INCLUDEDIR=${INCLUDEDIR-/usr/include}
  114.  
  115. rm -f conftest conftest.c
  116. compile="$CC $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1"
  117.  
  118. # Check for various header files.
  119.  
  120. echo checking for limits.h
  121. test -f $INCLUDEDIR/limits.h || DEFS="$DEFS -DLIMITS_MISSING"
  122.  
  123. echo checking for sys/mkdev.h
  124. if test -f $INCLUDEDIR/sys/mkdev.h; then
  125.   DEFS="$DEFS -DMAJOR_IN_MKDEV"
  126. fi
  127.  
  128. echo checking for directory library header
  129. if test -f $INCLUDEDIR/dirent.h; then
  130.   DEFS="$DEFS -DDIRENT"
  131. elif test -f $INCLUDEDIR/sys/ndir.h; then
  132.   DEFS="$DEFS -DSYSNDIR"
  133. elif grep 'void.*closedir' $INCLUDEDIR/sys/dir.h >/dev/null 2>&1; then
  134.   DEFS="$DEFS -DVOID_CLOSEDIR"
  135. fi
  136.  
  137. echo checking for st_blocks in struct stat
  138. echo "#include <sys/types.h>
  139. #include <sys/stat.h>
  140. main() { struct stat s; exit(0); s.st_blocks; }" > conftest.c
  141. eval $compile
  142. if test -s conftest && ./conftest 2>/dev/null; then :
  143. else
  144.   DEFS="$DEFS -DST_BLOCKS_MISSING"
  145.   LIBOBJS="$LIBOBJS fileblocks.o"
  146. fi
  147. rm -f conftest conftest.c
  148.  
  149. echo checking how to get filesystem type
  150. if test -f $INCLUDEDIR/sys/statvfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then
  151.   DEFS="$DEFS -DFS_STATVFS"
  152. elif test -f $INCLUDEDIR/sys/statfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then
  153.   DEFS="$DEFS -DFS_USG_STATFS"
  154. elif test -f $INCLUDEDIR/sys/statfs.h -a -f $INCLUDEDIR/sys/vmount.h; then
  155.   DEFS="$DEFS -DFS_AIX_STATFS"
  156. elif test -f $INCLUDEDIR/mntent.h; then
  157.   DEFS="$DEFS -DFS_MNTENT"
  158. elif test -f $INCLUDEDIR/sys/mount.h -a -f $INCLUDEDIR/sys/fs_types.h; then
  159.   DEFS="$DEFS -DFS_GETMNT"
  160. elif grep MOUNT_UFS $INCLUDEDIR/sys/mount.h >/dev/null 2>&1; then
  161.   DEFS="$DEFS -DFS_STATFS"
  162. fi
  163.  
  164. echo checking for ANSI C header files
  165. echo "#include <stdlib.h>
  166. #include <string.h>
  167. main() { exit(0); strerror(0); }" > conftest.c
  168. eval $compile
  169. if test -s conftest && ./conftest 2>/dev/null; then
  170.   DEFS="$DEFS -DSTDC_HEADERS"
  171. fi
  172. rm -f conftest conftest.c
  173.  
  174. echo checking for POSIX.1 header files
  175. echo "#include <unistd.h>
  176. main() {
  177. #ifdef _POSIX_VERSION
  178. exit(0);
  179. #else
  180. exit(1);
  181. #endif
  182. }" > conftest.c
  183. eval $compile
  184. if test -s conftest && ./conftest 2>/dev/null; then
  185.   DEFS="$DEFS -DPOSIX"
  186. fi
  187. rm -f conftest conftest.c
  188.  
  189. echo checking for BSD string and memory functions
  190. echo "#include <strings.h>
  191. main() { exit(0); rindex(0, 0); bzero(0, 0); }" > conftest.c
  192. eval $compile
  193. if test -s conftest && ./conftest 2>/dev/null; then :
  194.   else DEFS="$DEFS -DUSG"
  195. fi
  196. rm -f conftest conftest.c
  197.  
  198. # Check whether various functions exist.
  199.  
  200. # Functions we provide replacements for.
  201. for func in fnmatch memset stpcpy strdup strftime strspn strstr strtol
  202. do
  203.   echo checking for $func
  204.   echo "main() { exit(0); ${func}(); }" > conftest.c
  205.   eval $compile
  206.   if test -s conftest && ./conftest 2>/dev/null; then :
  207.   else LIBOBJS="$LIBOBJS ${func}.o"
  208.   fi
  209.   rm -f conftest conftest.c
  210. done
  211.  
  212. case "$LIBOBJS" in
  213. *strftime.o*)
  214.   echo checking whether struct tm has tm_zone
  215.   echo '#include <sys/types.h>' > conftest.c
  216.   case "$DEFS" in
  217.     *-DTM_IN_SYS_TIME*) echo '#include <sys/time.h>' >> conftest.c ;;
  218.     *) echo '#include <time.h>' >> conftest.c ;;
  219.   esac
  220.   echo 'main() { struct tm tm; exit(0); tm.tm_zone; }' >> conftest.c
  221.   eval $compile
  222.   if test -s conftest && ./conftest 2>/dev/null; then :
  223.   else DEFS="$DEFS -DTM_ZONE_MISSING"
  224.   fi
  225.   rm -f conftest conftest.c
  226.  
  227.   case "$DEFS" in
  228.     *-DTM_ZONE_MISSING*)
  229.     echo checking for tzname
  230.     echo '
  231. main() { extern char *tzname[2]; exit(tzname[0][0] == 1); }' > conftest.c
  232.     eval $compile
  233.     if test -s conftest && ./conftest 2>/dev/null; then :
  234.     else DEFS="$DEFS -DTZNAME_MISSING"
  235.     fi
  236.     rm -f conftest conftest.c
  237.     ;;
  238.   esac
  239.   ;;
  240. esac # strftime.o
  241.  
  242. # Functions whose absence we work around.
  243. for func in vprintf
  244. do
  245.   echo checking for $func
  246.   echo "main() { exit(0); ${func}(); }" > conftest.c
  247.   eval $compile
  248.   if test -s conftest && ./conftest 2>/dev/null; then :
  249.   else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
  250.   fi
  251.   rm -f conftest conftest.c
  252. done
  253.  
  254. case "$DEFS" in
  255. *VPRINTF_MISSING*)
  256.   func=_doprnt
  257.   echo checking for $func
  258.   echo "main() { exit(0); ${func}(); }" > conftest.c
  259.   eval $compile
  260.   if test -s conftest && ./conftest 2>/dev/null; then :
  261.   else DEFS="$DEFS -DDOPRNT_MISSING"
  262.   fi
  263.   rm -f conftest conftest.c
  264.   ;;
  265. esac
  266.  
  267. # Check other misc. things.
  268.  
  269. echo checking for unsigned characters
  270. echo 'main() { char c = 255; exit(c < 0); }' > conftest.c
  271. eval $compile
  272. if test -s conftest && ./conftest 2>/dev/null; then
  273.   DEFS="$DEFS -DCHAR_UNSIGNED"
  274. fi
  275. rm -f conftest conftest.c
  276.  
  277. echo checking for Minix
  278. if test -d /usr/include/minix; then
  279.   DEFS="$DEFS -UUSG -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX"
  280. fi
  281.  
  282. echo checking for Xenix
  283. if test -f /xenix; then
  284.   LIBS="$LIBS -lx"
  285.   case "$DEFS" in
  286.   *SYSNDIR*) ;;
  287.   *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx.
  288.   esac
  289. fi
  290.  
  291. echo checking how to get alloca
  292. echo '
  293. #ifdef __GNUC__
  294. #define alloca __builtin_alloca
  295. #else
  296. #ifdef sparc
  297. #include <alloca.h>
  298. #else
  299. #ifdef _AIX
  300.  #pragma alloca
  301. #else
  302. char *alloca ();
  303. #endif
  304. #endif
  305. #endif
  306. main() { char *p = (char *) alloca(1); exit(0); }' > conftest.c
  307. eval $compile
  308. if test -s conftest && ./conftest 2>/dev/null; then :
  309. elif test -d /usr/ucblib; then LIBS="$LIBS -L/usr/ucblib -lucb"
  310. else LIBS="$LIBS -lPW"
  311. fi
  312. rm -f conftest conftest.c
  313.  
  314. trap 'rm -f Makefile lib/Makefile find/Makefile xargs/Makefile locate/Makefile man/Makefile config.status; exit 1' 1 3 15
  315.  
  316. for dir in . lib find xargs locate man
  317. do
  318.   test -d $dir || mkdir $dir
  319.   echo '# Generated automatically from Makefile.in by configure.' > $dir/Makefile
  320.   sed -e "
  321. $vpsub
  322. s,@srcdir@,$srcdir,
  323. s,@VPATH@,$VPATH,
  324. s,@CC@,$CC,
  325. s,@RANLIB@,$RANLIB,
  326. s,@INSTALL@,$INSTALL,
  327. s,@INSTALLDATA@,$INSTALLDATA,
  328. s,@DEFS@,$DEFS,
  329. s,@LIBS@,$LIBS,
  330. s,@LIBOBJS@,$LIBOBJS,
  331. " $srcdir/$dir/Makefile.in >> $dir/Makefile
  332. done
  333.  
  334. echo "CC = $CC
  335. RANLIB = $RANLIB
  336. INSTALL = $INSTALL
  337. INSTALLDATA = $INSTALLDATA
  338. DEFS = $DEFS
  339. LIBS = $LIBS
  340. LIBOBJS = $LIBOBJS" > config.status
  341.